# coding:utf-8
import sys

import pygame
from pygame.locals import *

# 初始化pygame环境
pygame.init()

# 创建一个长宽分别为800/480窗口
canvas = pygame.display.set_mode((800, 480))
canvas.fill((255, 255, 255))

# 设置窗口标题
pygame.display.set_caption("捕鱼达人")

# 加载图片
net = pygame.image.load("images/net.png")
fish = []
for i in range(10):
	print("images/fish10_{}.png".format(i))
	fish.append(pygame.image.load("images/fish10_{}.png".format(i)))

print(len(fish))
bg = pygame.image.load("images/bg.jpg")


def handleEvent():
	for event in pygame.event.get():
		if event.type == QUIT:
			pygame.quit()
			sys.exit()


# 背景(bg)坐标为(0,0)
# 渔网(net)坐标为(300,300)
# 鱼(fish1)坐标为(300,100)
x = 800
count = 0
i = 0
while True:
	# 下方写你的代码
	canvas.blit(bg,(0,0))
	if count % 2 == 0:
		i += 1
		if i >= len(fish):
			i = 0
	canvas.blit(fish[i],(x,200))
	x = x - 3
	# 更新屏幕内容
	count = count + 2
	pygame.display.update()
	# 处理关闭游戏
	handleEvent()
